package us.mmapp.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import us.mmapp.HomeScreenActivity;

public class FileNameUtil
{
	public final static int AUDIO=2;
	public final static int PICTURE=0;
	public final static int VIDEO=1;
	private final static String videoType="m4v";
	private final static String audioType="3gp";
	private final static String pictureType="jpg";
	public static String getName(int fileType)
	{
		Calendar calendar = Calendar.getInstance();
		SimpleDateFormat f=new SimpleDateFormat("yyyyMMdd_HHmmss");
		if(fileType==AUDIO)
		{
			
			return HomeScreenActivity.AUDIO_LOCATION+"SND_"+f.format(calendar.getTime())+"."+audioType;
		}
		else if(fileType==PICTURE)
		{
			return HomeScreenActivity.PICTURE_LOCATION+"IMG_"+f.format(calendar.getTime())+"."+pictureType;
		}
		else if(fileType==VIDEO)
		{
			return HomeScreenActivity.VIDEO_LOCATION+"VID_"+f.format(calendar.getTime())+"."+videoType;
		}

		return null;
	}
	public static int getFileType(String fileName)
	{
		if(fileName.substring(fileName.length()-3).equals(audioType))
		{
			return AUDIO;
		}
		else if(fileName.substring(fileName.length()-3).equals(pictureType))
		{
			return PICTURE;
		}
		else if(fileName.substring(fileName.length()-3).equals(videoType))
		{
			return VIDEO;
		}
		return -1;
	}
}
